package com.lancoo.answer.widget.combinationView;

import android.content.Context;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.ivan.GlideEngine;
import com.ivan.easyphotos.EasyPhotos;
import com.lancoo.answer.R;
import com.lancoo.answer.model.AnswerConstant;
import com.lancoo.answer.model.ConstantBean;
import com.lancoo.answer.model.bean.Child;
import com.lancoo.answer.model.bean.CompositionComment;
import com.lancoo.answer.model.bean.DetailComment;
import com.lancoo.answer.model.bean.Item;
import com.lancoo.answer.model.entity.TaskControlBean;
import com.lancoo.answer.model.eventBean.CommentDetailEventBean;
import com.lancoo.answer.util.DpUtils;
import com.lancoo.answer.util.ExamFontSizeAdjustUtils;
import com.lancoo.answer.util.RichTextUtils;
import com.lancoo.answer.util.paperUtils.ChildRightOrWrongJudgeUtils;
import com.lancoo.answer.util.paperUtils.DecimalFormatUtils;
import com.lancoo.answer.view.activity.CompositionCommentActivity;
import com.lancoo.answer.view.fragment.composition.adapter.ImageAdapter;
import com.lancoo.answer.widget.PcDialog;
import com.lancoo.answer.widget.span.CenteredImageSpan;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by pengmi on 2021/12/14 10:58
 * Description:听写题等主观题查看评阅状态view
 */
public class WritingAnswerResultView extends RelativeLayout implements View.OnClickListener{

    private static final String TAG = "AnswerAnalysisView";
    private Child child;
    private TextView tv_score;
    private Item item;
    private long clickTime;
    private String quesID;

    public WritingAnswerResultView(Context context) {
        super(context);
        init(context);
    }

    public WritingAnswerResultView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public WritingAnswerResultView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }


    private void init(Context context){
        LayoutInflater.from(context).inflate(R.layout.ev_layout_writing_answer_result,this);
        TextView tv_title=findViewById(R.id.tv_score_des);
        TextView tv_title1=findViewById(R.id.tv_answer_des);
        TextView tv_title2=findViewById(R.id.tv_my_answer_des);
        TextView tv_title3=findViewById(R.id.tv_my_score);
        TextView tv_title4=findViewById(R.id.tv_comment_des);
        String str="【";
        float v = tv_title.getPaint().measureText(str);
        tv_title.setTranslationX(-v/2);
        tv_title1.setTranslationX(-v/2);
        tv_title2.setTranslationX(-v/2);
        tv_title3.setTranslationX(-v/2);
        tv_title4.setTranslationX(-v/2);
        adjustFontSize();

    }

    public void setWriteResult(Child child,String generID,String quesID){
        this.quesID=quesID;
        this.child=child;
        this.item = child.getItemList().get(0);
        AnswerAnalysisView answerAnalysisView = findViewById(R.id.answer_analysis_view);
        answerAnalysisView.setAnalysis(child.getChildAnalysis());
        answerAnalysisView.setAlignmentType(1);
        TextView tv_answer=findViewById(R.id.tv_answer);
        String childAnswer = child.getChildAnswer();
        showComment();
        if(TextUtils.isEmpty(childAnswer)){
            tv_answer.setText(R.string.ev_item_null);
        }else{
            String replaceStr=tv_answer.getResources().getString(R.string.ev_standard_answer_replace);
            tv_answer.setText(RichTextUtils.getQueseAnswerStr(childAnswer.replace("$/",replaceStr).replace("$、","、"),
                    child.getIsIndentChildAnswer(),TextUtils.equals("39",generID)));
        }
        updateScoreState();
        final Item item = child.getItemList().get(0);
        TextView tv_myAnswer= findViewById(R.id.tv_my_answer);
        if(!TextUtils.isEmpty(item.getScanImagePath())){
            ImageView img_scanner = findViewById(R.id.img_scanner);
            img_scanner.setVisibility(VISIBLE);
            Glide.with(img_scanner.getContext())
                    .load(item.getScanImagePath())
                    .into(img_scanner);
            findViewById(R.id.tv_my_answer).setVisibility(GONE);
            return;
        }
        TaskControlBean taskControlBean = ConstantBean.Companion.getTaskControlBean();
        if(taskControlBean.getExpired()){
            List<String> imagePath = item.getImagePathList();
            String stuAnswer = item.getStuAnswer();
            switch (item.getWrittingAnswerType()){
                case AnswerConstant.ANSWER_TYPE_PICTURE:
                    if (imagePath != null && imagePath.size() > 0 &&
                            !TextUtils.isEmpty(imagePath.get(0))) {
                        tv_myAnswer.setVisibility(GONE);
                        RecyclerView mRecyclerView = findViewById(R.id.recyclerView);
                        mRecyclerView.setVisibility(VISIBLE);
                        mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.HORIZONTAL,false));
                        ImageAdapter mAdapter = new ImageAdapter(item.getImagePathList(),1);
                        mAdapter.setImageOperateCallBack(new ImageAdapter.ImageOperateCallBack() {
                            @Override
                            public void gotoImageLibChoice() {
                            }

                            @Override
                            public void deletChoiceImage(int position){
                            }

                            @Override
                            public void lookChoiceImage(int position){
                                EasyPhotos.startPreviewPaths((FragmentActivity) getContext(), GlideEngine.getInstance(),(ArrayList<String>) item.getImagePathList(),true,position);
                            }

                        });
                        mRecyclerView.setAdapter(mAdapter);
                        int dp8= DpUtils.dip2px(getContext(),12);
                        LayoutParams layoutParams = (LayoutParams) mRecyclerView.getLayoutParams();
                        layoutParams.setMarginStart(-dp8);
                        layoutParams.setMarginEnd(0);
                        layoutParams.topMargin=dp8;
                        mRecyclerView.setLayoutParams(layoutParams);
                        loadHPMode(this);
                        if(ConstantBean.Companion.getTaskControlBean().getTrainSence()==0){
                            return;
                        }
                        if(!TextUtils.isEmpty(stuAnswer)&&!TextUtils.isEmpty(stuAnswer.trim())){
                            tv_myAnswer.setText(stuAnswer);
                            tv_myAnswer.setVisibility(VISIBLE);
                        }
                    }else{
                        tv_myAnswer.setText(R.string.ev_no_answer);
                        tv_myAnswer.setVisibility(VISIBLE);
                        findViewById(R.id.tv_ev_des).setVisibility(GONE);
                    }
                    break;
                default:
                    if (TextUtils.isEmpty(stuAnswer)) {
                        tv_myAnswer.setText(R.string.ev_no_answer);
                        tv_myAnswer.setVisibility(VISIBLE);
                        findViewById(R.id.tv_ev_des).setVisibility(GONE);
                    }else{
                        tv_myAnswer.setText(stuAnswer);
                        tv_myAnswer.setVisibility(VISIBLE);
                    }
            }
            return;
        }


        if(!TextUtils.isEmpty(item.getAudioPath())){
            ChildAudioView childAudioView=findViewById(R.id.child_audio_view);
            tv_myAnswer.setVisibility(GONE);
            childAudioView.setVisibility(VISIBLE);
            childAudioView.setAudioPath(item.getAudioPath());
            childAudioView.setAudioTxt(R.string.ev_my_audio);
            return;
        }
        if(item.getImagePathList()!=null&&item.getImagePathList().size()>0){
            tv_myAnswer.setVisibility(GONE);
            RecyclerView mRecyclerView = findViewById(R.id.recyclerView);
            mRecyclerView.setVisibility(VISIBLE);
            mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.HORIZONTAL,false));
            ImageAdapter mAdapter = new ImageAdapter(item.getImagePathList(),1);
            mAdapter.setImageOperateCallBack(new ImageAdapter.ImageOperateCallBack() {
                @Override
                public void gotoImageLibChoice() {
                }

                @Override
                public void deletChoiceImage(int position){
                }

                @Override
                public void lookChoiceImage(int position){
                    EasyPhotos.startPreviewPaths((FragmentActivity) getContext(), GlideEngine.getInstance(),(ArrayList<String>) item.getImagePathList(),true,position);
                }

            });
            mRecyclerView.setAdapter(mAdapter);
            int dp8= DpUtils.dip2px(getContext(),12);
            LayoutParams layoutParams = (LayoutParams) mRecyclerView.getLayoutParams();
            layoutParams.setMarginStart(-dp8);
            layoutParams.setMarginEnd(0);
            layoutParams.topMargin=dp8;
            mRecyclerView.setLayoutParams(layoutParams);
            String stuAnswer = item.getStuAnswer();

            loadHPMode(this);
//            if(ConstantBean.Companion.getTaskControlBean().getTrainSence()==0){
//                return;
//            }
            if(!TextUtils.isEmpty(stuAnswer)&&!TextUtils.isEmpty(stuAnswer.trim())){
                tv_myAnswer.setText(stuAnswer);
                tv_myAnswer.setVisibility(VISIBLE);
            }
            String imgRecognitionTxt = item.getImgRecognitionTxt();
            if(!TextUtils.isEmpty(imgRecognitionTxt)&&!TextUtils.isEmpty(imgRecognitionTxt.trim())){
                tv_myAnswer.setText(imgRecognitionTxt);
                tv_myAnswer.setVisibility(VISIBLE);
            }
            return;
        }
        String stuAnswer = item.getStuAnswer();
        if(!TextUtils.isEmpty(item.getImgRecognitionTxt())){
            stuAnswer=item.getImgRecognitionTxt();
        }
        Log.e("eee","学生作答："+stuAnswer);
        if(TextUtils.isEmpty(stuAnswer)||TextUtils.isEmpty(stuAnswer.trim())){
            tv_myAnswer.setText(R.string.ev_no_answer);
        }else{
            tv_myAnswer.setText(stuAnswer);
        }
        if(child.getItemList().size()>1&&(TextUtils.equals(generID,"0"))){
            StringBuilder stringBuffer=new StringBuilder();
            for (Item it:child.getItemList()){
                stuAnswer=it.getStuAnswer();
                if(!TextUtils.isEmpty(stringBuffer.toString())){
                    stringBuffer.append("、");
                }
                if(stuAnswer==null||TextUtils.isEmpty(stuAnswer)||TextUtils.isEmpty(stuAnswer.trim())){
                    stringBuffer.append(getContext().getString(R.string.ev_no_answer));
                }else{
                    stringBuffer.append(it.getStuAnswer().trim());
                }
            }
            tv_myAnswer.setText(stringBuffer.toString());
        }
        if(child.getItemList().size()>1&&(TextUtils.equals(generID,"107"))){
            StringBuilder stringBuffer=new StringBuilder();
            boolean isAnswer=false;
            int index=0;
            for (Item it:child.getItemList()){
                stuAnswer=it.getStuAnswer();
                if(index!=0){
                    stringBuffer.append("、");
                }
                if(stuAnswer==null||TextUtils.isEmpty(stuAnswer)||TextUtils.isEmpty(stuAnswer.trim())){
                    stringBuffer.append("");
                }else{
                    stringBuffer.append(it.getStuAnswer().trim());
                    isAnswer=true;
                }
                index++;
            }
            if(isAnswer){
                tv_myAnswer.setText(stringBuffer.toString());
            }else{
                tv_myAnswer.setText(R.string.ev_no_answer);
            }
        }
        loadHPMode(this);

    }


    /**
     * 更新作答得分
     */
    public void updateScoreState(){
        if(child==null){
            return;
        }
        TextView tv_myScore=findViewById(R.id.tv_my_score);
        TextView tv_scorDes=findViewById(R.id.tv_score_des);
        float evalScore = child.getItemList().get(0).getEvalScore();
        String s = DecimalFormatUtils.RoundToTheNearestDecimalPlace1(evalScore);
        tv_myScore.setText(String.format("%s分", s));
        int state= ChildRightOrWrongJudgeUtils.judgeChildAnswerState(child);
        Log.e(TAG, "setFillResult: "+state );
        switch (state){
            case 0:
                tv_myScore.setTextColor(0xffff4d4d);
                tv_scorDes.setTextColor(0xffff4d4d);
                break;
            case 1:
                tv_myScore.setTextColor(0xff00c063);
                tv_scorDes.setTextColor(0xff00c063);
                break;
            case 2:
                tv_myScore.setText("--");
                tv_myScore.setTextColor(0xff0099ff);
                tv_scorDes.setTextColor(0xff0099ff);
                break;
        }
        TaskControlBean taskControlBean = ConstantBean.Companion.getTaskControlBean();
        if(taskControlBean.getExpired()){
            tv_myScore.setVisibility(GONE);
            tv_scorDes.setVisibility(GONE);
            TextView tv_title=findViewById(R.id.tv_my_answer_des);
            LayoutParams layoutParams = (LayoutParams) tv_title.getLayoutParams();
            layoutParams.topMargin=0;
            tv_title.setLayoutParams(layoutParams);
        }
        if(taskControlBean==null||taskControlBean.getShowLookingScoreType()==0){
            return;
        }
        tv_scorDes.setText(R.string.ev_answer_score_rate);
        if(state!=2){
            tv_myScore.setText(String.format("%s%%", (int) (child.getItemList().get(0).getScoreRate() * 100)));
        }

    }

    public void onPause(){
        ChildAudioView childAudioView=  findViewById(R.id.child_audio_view);
        if(childAudioView!=null){
            childAudioView.pause();
        }
    }
    public void release(){
        ChildAudioView childAudioView=  findViewById(R.id.child_audio_view);
        if(childAudioView!=null){
            childAudioView.release();
        }
    }


    private boolean isAnsweredEmpty(Item item){
        if (!TextUtils.isEmpty(item.getStuAnswer())){
            return false;
        }else if (item.getImagePathList() != null &&item.getImagePathList().size()>0){
            return false;
        }else if (!TextUtils.isEmpty(item.getVideoPath())){
            return false;
        }else if (!TextUtils.isEmpty(item.getAudioPath())){
            return false;
        }
        return true;
    }


    private void loadHPMode(View view){
        if (ConstantBean.Companion.getTaskControlBean().isHp()){
            Log.e("aaaa","loadHPMode");
            view.findViewById(R.id.tv_score_des).setVisibility(INVISIBLE);
            view.findViewById(R.id.tv_my_score).setVisibility(GONE);
            LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            params.addRule(RelativeLayout.BELOW,R.id.scoreLayout);
            view.findViewById(R.id.tv_my_answer_des).setLayoutParams(params);

            view.findViewById(R.id.tv_ev_des).setVisibility(VISIBLE);
            view.findViewById(R.id.ll_score).setVisibility(VISIBLE);
            TextView tv_total = findViewById(R.id.totalScoreTv);
            tv_score = findViewById(R.id.scoreTv);
            if (item.getMutEvaluateScore()==-1){
                tv_score.setText("请评分...");
            }else {
                tv_score.setText(DecimalFormatUtils.RoundToTheNearestDecimalPlace1(item.getMutEvaluateScore()));
            }
            tv_total.setText("分 (总分" + DecimalFormatUtils.RoundToTheNearestDecimalPlace(item.getTotalScore()) + "分)");
            tv_score = view.findViewById(R.id.scoreTv);


            if (isAnsweredEmpty(item)){
                view.findViewById(R.id.addBtn).setBackgroundResource(R.drawable.ev_shape_pc_right_test_gray);
                view.findViewById(R.id.reduceBtn).setBackgroundResource(R.drawable.ev_subject_card_shape_pc_left_test_gray);
//                view.findViewById(R.id.scoreTv).setBackgroundResource(R.drawable.ev_shape_pc_right_test_gray);
                tv_score.setText("0");
            }else {
                view.findViewById(R.id.addBtn).setBackgroundResource(R.drawable.ev_shape_pc_right_test);
                view.findViewById(R.id.reduceBtn).setBackgroundResource(R.drawable.ev_subject_card_shape_pc_left_test);
                view.findViewById(R.id.scoreTv).setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        showPcDialog(item.getMutEvaluateScore(),item.getTotalScore());
                    }
                });
                view.findViewById(R.id.addBtn).setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        addScore();
                    }
                });
                view.findViewById(R.id.reduceBtn).setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        reduceScore();
                    }
                });
            }


        }else {
            view.findViewById(R.id.ll_score).setVisibility(GONE);
            view.findViewById(R.id.tv_ev_des).setVisibility(GONE);
        }

    }

    private void showPcDialog(float score,float total){
        PcDialog pcDialog = new PcDialog(getContext());
        pcDialog.setOnPcEnsureListener(score1 -> {
            item.setMutEvaluateScore(score1);
            tv_score.setText(DecimalFormatUtils.RoundToTheNearestDecimalPlace1(score1));
        });
        pcDialog.show(score,total);
    }

    private void addScore(){
        if (item.getMutEvaluateScore()>=0 && checkScoreRange(item.getMutEvaluateScore()+0.5f)){
            return;
        }
        float score = item.getMutEvaluateScore();
        if (score==-1){
            score = 0;
        }
        score += 0.5f;

        item.setMutEvaluateScore(score);
        tv_score.setText(DecimalFormatUtils.RoundToTheNearestDecimalPlace1(score));
    }

    private boolean checkScoreRange(float score){
        if (score > item.getTotalScore()){
            Toast.makeText(getContext(), "输入分值不能大于总分", Toast.LENGTH_SHORT).show();
            return true;
        }
        if (score<0){
            Toast.makeText(getContext(), "输入分值不能小于0", Toast.LENGTH_SHORT).show();
            return true;
        }
        return false;
    }

    private void reduceScore(){
        if (item.getMutEvaluateScore()>=0 && checkScoreRange(item.getMutEvaluateScore()-0.5f)){
            return;
        }

        float score = item.getMutEvaluateScore();
        if (score==-1){
            score = 0;
        }
        score -= 0.5f;

        item.setMutEvaluateScore(score);
        tv_score.setText(DecimalFormatUtils.RoundToTheNearestDecimalPlace1(score));
    }

    //展示评语
    private void showComment(){

        List<Item> itemList = child.getItemList();
        if(itemList!=null&&itemList.size()>1){
            RecyclerView mRecyclerView = findViewById(R.id.rv_comment);
            mRecyclerView.setVisibility(VISIBLE);
            mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
            CommentAdapter mAdapter=new CommentAdapter(itemList,quesID);
            mRecyclerView.setAdapter(mAdapter);
            return;
        }
        String comment = item.getComment();
        if(comment==null||TextUtils.isEmpty(comment)){
            return;
        }
        findViewById(R.id.tv_comment).setVisibility(VISIBLE);
        findViewById(R.id.tv_comment_des).setVisibility(VISIBLE);
        TextView tv_comment = findViewById(R.id.tv_comment);

        findViewById(R.id.tv_comment).setOnClickListener(this);
        findViewById(R.id.tv_comment_des).setOnClickListener(this);
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
        spannableStringBuilder.append(comment.trim());
        SpannableString spannableString = new SpannableString("123");
        spannableString.setSpan(new CenteredImageSpan(tv_comment.getContext(), R.drawable.ev_vector_comment_details), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        spannableStringBuilder.append(" ");
        spannableStringBuilder.append(spannableString);
        tv_comment.setText(spannableStringBuilder);
    }


    @Override
    public void onClick(View v) {
        if (System.currentTimeMillis() - clickTime < 500) {
            return;
        }
        clickTime = System.currentTimeMillis();
        int id = v.getId();
        if (id == R.id.tv_comment_des || id == R.id.tv_comment) {
            List<Item> itemList = child.getItemList();
            if(itemList==null){
                return;
            }
            Item item = itemList.get(child.getSelectedItemIndex());
            gotoCommentDetails(item);
        }
    }


    private void gotoCommentDetails(Item item){
        DetailComment detailComment = item.getDetailComment();
        if(detailComment==null){
            CommentDetailEventBean bean=new CommentDetailEventBean();
            bean.setAnswerPointIndex(item.getAnswerPointIndex());
            bean.setQuesID(quesID);
            bean.setItemIndex(item.getItemIndex());
            bean.setQuesIndex(0);
            bean.setCommentType(1);
            bean.setChildIndex(0);
            EventBus.getDefault().post(bean);
            return;
        }
        String comment = item.getComment();
        float evalScore = item.getEvalScore();
        float totalScore = item.getTotalScore();
        CompositionComment bean=new CompositionComment(comment==null?"":comment,evalScore,totalScore,detailComment);
        //查看评语详情
        CompositionCommentActivity.Companion.launch(getContext(), bean, 1, 1);
    }


    private static class CommentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{

        private final List<Item> itemList;
        private final String quesID;

        public CommentAdapter(List<Item> itemList,String quesID) {
            this.itemList = itemList;
            this.quesID=quesID;
        }

        @NonNull
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.ev_layout_item_commend, parent, false);
            return new VH(inflate,quesID);
        }

        @Override
        public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
            VH vh= (VH) holder;
            vh.initData(itemList.get(position));
        }

        @Override
        public int getItemCount() {
            return itemList.size();
        }

        private static class VH extends RecyclerView.ViewHolder implements View.OnClickListener{

            private Item item;
            private final String quesID;

            public VH(@NonNull View itemView,String quesID) {
                super(itemView);
                this.quesID=quesID;
                TextView view = itemView.findViewById(R.id.tv_comment_des);
                String str="【";
                float v = view.getPaint().measureText(str);
                view.setTranslationX(-v/2);
                itemView.findViewById(R.id.tv_comment).setOnClickListener(this);
                itemView.findViewById(R.id.tv_comment_des).setOnClickListener(this);
                adjustFontSize();
            }

            private void initData(Item item){
                this.item=item;

                TextView tv_comment = itemView.findViewById(R.id.tv_comment);
                TextView commentDes = itemView.findViewById(R.id.tv_comment_des);
                commentDes.setText(String.format("【评语%s】", getBindingAdapterPosition() + 1));
                String comment = item.getComment();
                if(comment==null){
                    comment="";
                }
                if(TextUtils.isEmpty(comment)){
                    itemView.setVisibility(GONE);
                    tv_comment.setVisibility(GONE);
                    commentDes.setVisibility(GONE);
                }else{
                    itemView.setVisibility(VISIBLE);
                    tv_comment.setVisibility(VISIBLE);
                    commentDes.setVisibility(VISIBLE);
                }
                SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
                spannableStringBuilder.append(comment.trim());
                SpannableString spannableString = new SpannableString("123");
                spannableString.setSpan(new CenteredImageSpan(tv_comment.getContext(), R.drawable.ev_vector_comment_details), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                spannableStringBuilder.append(" ");
                spannableStringBuilder.append(spannableString);
                tv_comment.setText(spannableStringBuilder);
            }

            private void adjustFontSize(){
                TextView textView = itemView.findViewById(R.id.tv_comment);
                TextView textView1 = itemView.findViewById(R.id.tv_comment_des);
                ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView1,14);
                ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView,13);
            }

            @Override
            public void onClick(View view) {
                gotoCommentDetails(item);
            }


            private void gotoCommentDetails(Item item){
                DetailComment detailComment = item.getDetailComment();
                if(detailComment==null){
                    CommentDetailEventBean bean=new CommentDetailEventBean();
                    bean.setAnswerPointIndex(item.getAnswerPointIndex());
                    bean.setQuesID(quesID);
                    bean.setItemIndex(item.getItemIndex());
                    bean.setItemIndexInChild(getBindingAdapterPosition());
                    bean.setQuesIndex(0);
                    bean.setCommentType(1);
                    bean.setChildIndex(0);
                    EventBus.getDefault().post(bean);
                    return;
                }
                String comment = item.getComment();
                float evalScore = item.getEvalScore();
                float totalScore = item.getTotalScore();
                CompositionComment bean=new CompositionComment(comment==null?"":comment,evalScore,totalScore,detailComment);
                //查看评语详情
                CompositionCommentActivity.Companion.launch(itemView.getContext(), bean, 1, 1);
            }
        }
    }


    public void adjustFontSize(){
        TextView textView = findViewById(R.id.tv_score_des);
        TextView textView1 = findViewById(R.id.tv_my_score);
        TextView textView2 = findViewById(R.id.tv_my_answer_des);
        TextView textView3 = findViewById(R.id.tv_my_answer);
        TextView textView4 = findViewById(R.id.tv_comment_des);
        TextView textView5 = findViewById(R.id.tv_comment);
        TextView textView6 = findViewById(R.id.tv_answer_des);
        TextView textView7 = findViewById(R.id.tv_answer);
        ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView,14);
        ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView1,13);
        ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView2,14);
        ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView3,13);
        ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView4,14);
        ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView5,13);
        ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView6,14);
        ExamFontSizeAdjustUtils.adjustTextViewFontSize(textView7,13);
        AnswerAnalysisView answerAnalysisView=findViewById(R.id.answer_analysis_view);
        answerAnalysisView.adjustFontSize();
        ChildAudioView childAudioView=findViewById(R.id.child_audio_view);
        childAudioView.adjustFontSize();
        RecyclerView mRecyclerView = findViewById(R.id.rv_comment);
        RecyclerView.Adapter adapter = mRecyclerView.getAdapter();
        if(adapter!=null){
            adapter.notifyDataSetChanged();
        }
    }

}
